home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dynAddParticleAttr.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.2 KB  |  130 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  15 Aug 1997
  22. //  Author:         rh
  23. //
  24. //  Description:
  25. //      Add a render attribute to the particle shape. The attribute 
  26. //        description is passed in as attrInfo. The description comes
  27. //        from the render subclasses. It describes the name, type, min,
  28. //        max values, and what type of ui to build.
  29. //
  30.  
  31.  
  32. global proc  dynAddParticleAttr( string $nodeName, string $attrInfo )
  33. {
  34.     string  $cmd;
  35.     string  $tokenAry[];
  36.     int        $tokenCnt;
  37.     int        $makeKeyable = 1;
  38.  
  39.     tokenize( $attrInfo, ":", $tokenAry );
  40.     $tokenCnt = size( $tokenAry );
  41.  
  42.  
  43.     // Adding a string attr is a special case because we cannot use the
  44.     // default value (-dv) command.  We need to set the attribute
  45.     // seperately.
  46.     //
  47.     if (($tokenCnt >= 3) && ($tokenAry[2] == "textfield"))
  48.     {
  49.         $cmd = "addAttr -is true -dt \"string\" -ln \"" +$tokenAry[0]+ "\" " +$nodeName+";";
  50.         evalEcho $cmd;
  51.         $cmd = "setAttr -type \"string\" " + $nodeName+"."+$tokenAry[0] + " \"" + $tokenAry[1] + "\";";
  52.         evalEcho $cmd;
  53.     }
  54.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "toggleBtn"))
  55.     {
  56.         $cmd = "addAttr -is true -ln \""+$tokenAry[0]+"\" -at bool -dv "+$tokenAry[1]+" " +$nodeName+";";
  57.         evalEcho $cmd;
  58.     }
  59.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "intSlider"))
  60.     {
  61.         $cmd = "addAttr -is true -ln \""+$tokenAry[0]+"\" -at long -min "+$tokenAry[3]
  62.                 +" -max "+$tokenAry[4]+" -dv "+$tokenAry[1]+" " +$nodeName+";";
  63.         evalEcho $cmd;
  64.     }
  65.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "floatSlider"))
  66.     {
  67.         $cmd = "addAttr -is true -ln \""+$tokenAry[0]+"\" -at \"float\" -min "+$tokenAry[3]
  68.                 +" -max "+$tokenAry[4]+" -dv "+$tokenAry[1]+" " +$nodeName+";";
  69.         evalEcho $cmd;
  70.     }
  71.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "intField"))
  72.     {
  73.         $cmd = "addAttr -is true -ln \""+$tokenAry[0]+"\" -at long -dv "+$tokenAry[1]+" " +$nodeName+";";
  74.         evalEcho $cmd;
  75.     }
  76.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "vector"))
  77.     {
  78.         $cmd = "addAttr -is true -ln \""+$tokenAry[0]+"\" -dt double3 " +$nodeName+";";
  79.         evalEcho $cmd;
  80.         eval( "setAttr -type double3 "+$nodeName+"."+$tokenAry[0]+" 0 0 0;" );
  81.         $makeKeyable = 0;
  82.     }
  83.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "vectorArray"))
  84.     {
  85.         $makeKeyable = 0;
  86.         $cmd = "addAttr -ln "+$tokenAry[0]+" -dt vectorArray "+$nodeName+";";
  87.         evalEcho $cmd;
  88.  
  89.         // Add the initial state attribute.
  90.         //
  91.         $cmd = "addAttr -ln "+$tokenAry[0]+"0 -dt vectorArray "+$nodeName+";";
  92.         evalEcho $cmd;
  93.     }
  94.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "intArray"))
  95.     {
  96.         $makeKeyable = 0;
  97.         $cmd = "addAttr -ln "+$tokenAry[0]+" -dt Int32Array "+$nodeName+";";
  98.         evalEcho $cmd;
  99.  
  100.         // Add the initial state attribute.
  101.         //
  102.         $cmd = "addAttr -ln "+$tokenAry[0]+"0 -dt Int32Array "+$nodeName+";";
  103.         evalEcho $cmd;
  104.     }
  105.     else if (($tokenCnt >= 3) && ($tokenAry[2] == "floatArray"))
  106.     {
  107.         $makeKeyable = 0;
  108.         $cmd = "addAttr -ln "+$tokenAry[0]+" -dt doubleArray "+$nodeName+";";
  109.         evalEcho $cmd;
  110.  
  111.         // Add the initial state attribute.
  112.         //
  113.         $cmd = "addAttr -ln "+$tokenAry[0]+"0 -dt doubleArray "+$nodeName+";";
  114.         evalEcho $cmd;
  115.     }
  116.     else
  117.     {
  118.         $cmd = "addAttr -is true -ln \"" +$tokenAry[0]+ "\" -dv " +$tokenAry[1]+ " " +$nodeName+";";
  119.         evalEcho $cmd;
  120.     }
  121.  
  122.  
  123.     if ($makeKeyable)
  124.     {
  125.         setAttr -keyable true ($nodeName+"."+$tokenAry[0]);
  126.     }
  127.  
  128.  
  129. }  // dynAddParticleAttr //
  130.